﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;

namespace Hedgehog
{
    public class Circle : IFigure
    {
        public int offsetX { get; set; }
        public int offsetY { get; set; }
        private int _x;
        private int _y;
        private int _radius;

       public Circle(int X, int Y, int Radius) 
       {
           _x = X;
           _y = Y;
           _radius = Radius;
       }
    
       public void Draw(Graphics g)
       {
           
           bool firstIteration = true;
           int lastX =0;
           int lastY = 0;
           for (double fi = 0; fi < Math.PI * 2; fi += 0.1)
           {
               int newX = (int)(_radius * Math.Sin(fi))+_x+offsetX;
               int newY = (int)(_radius * Math.Cos(fi))+_y+offsetY;

               if (firstIteration)
               {
                   lastX = newX;
                   lastY = newY;
                   firstIteration = false;
                   continue;
               }

               g.DrawLine(Pens.Black, lastX, lastY, newX, newY);
               lastX = newX;
               lastY = newY;
           }

           
           
       }
       public bool ChekIfPointInside(int x, int y)
       {
           bool pointInside = false;
           if (_x - _radius +offsetX< x && x < _x + _radius+offsetX && y>_y-_radius+offsetY && y<_y+_radius+offsetY)
           {pointInside = true;
               int k = 0;
           }
           return pointInside;
       }

        public object Clone()
        {
            return new Circle(_x,_y,_radius);
        }
    }
}
